﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/UserMaster.master"
    Inherits="System.Web.Mvc.ViewPage<Eacademy.Domain.Models.QuestionListViewModel>" %>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <%--<script src="/content/js/jquery.countDown.js" type="text/javascript"></script>--%>
    <link href="/content/css/jquery.countdown.css" rel="stylesheet" type="text/css" />
    <script src="/content/js/jquery.countdown.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //$('#countdown').countDown({
            //    startNumber: <%=Model.TimeRemaining %>,
            //    callBack: function (me) {
            //        $(me).parent().html('Reached Time Limit').css('color', '#090').delay(400);
            //        $("input[type='submit'][id='quiz-submit']").click();
            //    }
            //});

            shortly = new Date();
            shortly.setSeconds(shortly.getSeconds() + <%=Model.TimeRemaining %>);
            $('#countdown').countdown({until: shortly, format: 'HMS', onExpiry: submitForm}); 

            function submitForm()
            {
                $("input[type='submit'][id='quiz-submit']").click();
            }

            $("input:radio").click(function () {
                var $obj = $(this);
                var answerid = $obj.val();
                var questionId = $("input[id$='QuestionId']",$obj.parents("div.question")).val();
                var quizStudentId = $("input[id$='QuizStudentId']").val();
                $.post('/student/quizzes/saveanswer',{choiceanswerid : answerid, quizstudentid: quizStudentId, questionid : questionId});
            });
        });

        function reloadPage() { location.reload(true); }
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Subjects
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3>
        Quiz - <a href="/student/quizzes/index/<%=Model.SubjectId+"?mentoruserid="+Model.MentorUserId %>"
            class="back">Back to List</a></h3>
    <div id="timeremaining">
        <div id="countdown">
        </div>
    </div>
    <% using (Html.BeginForm("Take", "Quizzes"))
       {%>
    <%
        for (int i = 0; i < Model.QuestionViewModelList.Count; i++)
        {%>
    <%:Html.EditorFor(model => model.QuestionViewModelList[i])%>
    <%
        }%>
    <div style="text-align: center;">
        <%: Html.HiddenFor(model => model.QuizId) %>
        <%: Html.HiddenFor(model => model.QuizStudentId) %>
        <input type="submit" name="submit" value="Submit" class="button-style" id="quiz-submit" />
    </div>
    <%
        }%>
    <%if (false)
      {%>
    <div class="event-paging">
        <div class="pager">
            <%
                if (Model.QuestionViewModelList.TotalItemCount > Model.QuestionViewModelList.PageSize)
                {%>
            <%=Html.Pager(Model.QuestionViewModelList.PageSize, Model.QuestionViewModelList.PageNumber,
                                           Model.QuestionViewModelList.TotalItemCount)%>
            <%
                }%>
        </div>
    </div>
    <%
        }%>
    <div id="dialog-confirm" title="Delete Question" style="display: none;">
        <p>
            Are you sure you want to delete this question?</p>
    </div>
</asp:Content>
